repo.or.cz
/
andmenj-acm.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Solving 10385 - Duathlon (Ternary search)
[andmenj-acm.git]
/
11428 - Cubes
/
b.cpp
blob
ea5ed4673c570ebc58f45cfb97ae17e278bca9ea
1
#include<iostream>
2
#include<math.h>
3
using namespace
std
;
4
int
main
(){
5
int
n
;
6
while
(
cin
>>
n
&&
n
){
7
double
aux
=(
1
.+
sqrt
(
1
.+(
8
.*
sqrt
((
double
)(
n
)))))/
2
;
8
aux
=
floor
(
aux
);
9
10
if
(
n
==(
aux
*
aux
*
aux
-(
aux
-
1
)*(
aux
-
1
)*(
aux
-
1
))){
11
cout
<<
aux
<<
" "
<<
aux
-
1
;
12
}
else
{
13
int
i
=
1
;
14
while
(
i
*
i
*
i
<= (
n
+
1
)){
15
++
i
;
16
}
17
--
i
;
18
// cout << i << endl;
19
if
(
i
*
i
*
i
==
n
+
1
){
20
cout
<<
i
<<
" 1"
;
21
}
else
{
22
cout
<<
"No solution"
;
23
}
24
}
25
cout
<<
endl
;
26
}
27
}